class AutoUserStationsController < ApplicationController
  layout "main"
  active_scaffold :auto_station do |config|
    config.label = '<br/>'
    config.list.per_page = 10
    config.actions = [:search, :list, :show]
    config.columns = [:id, :name, :province, :tel, :auto_course, :description, :round2, :show_image1, :show_image2, :show_image3, :show_image4, :show_code]
    config.columns[:auto_course].form_ui = :select
    config.columns[:auto_course].search_sql = 'courses.name'
    config.columns[:auto_course].sort_by :sql=>'courses.name'
    config.search.columns << :auto_course

    config.columns[:name].label = "ชื่อสนามสอบ"
    config.columns[:auto_course].label = "Course"
    config.columns[:province].label = "จังหวัด"
    config.columns[:tel].label = "โทรศัพท์"
    config.columns[:description].label = "รายละเอียด"
    config.columns[:show_image1].label = "รูปที่ 1"
    config.columns[:show_image2].label = "รูปที่ 2"
    config.columns[:show_image3].label = "รูปที่ 3"
    config.columns[:show_image4].label = "รูปที่ 4"
    config.columns[:round2].label = "รอบ"
    config.columns[:show_code].label = "Google Maps"

    config.list.columns.exclude :tel, :description, :show_image1, :show_image2, :show_image3, :show_image4, :show_code
    config.list.sorting = {:id => 'ASC'}
  end

  protected

  def conditions_for_collection
    ['auto_course_id=? AND s_status=?', session[:user_course_id], 'Active']
  end
end
